package com.kidback.bbloc259.network.errorhandler;

import androidx.annotation.Nullable;

import java.util.Locale;

/**
 * Created by meikai on 2020/05/16.
 * 网络返回错误
 * 整合：业务错误、客户端请求错误、服务器响应错误
 * 方便上层显示界面
 */
public class ResponseThrowable extends Throwable {

    public Throwable throwable;
    public int errorCode;
    public String message;

    public ResponseThrowable(Throwable throwable, int errorCode) {
        this.throwable = throwable;
        this.errorCode = errorCode;
    }

    @Override
    public String toString() {
        return String.format(Locale.getDefault(), "错误编码: %d\n错误消息: %s", errorCode, message);
    }


    @Nullable
    @Override
    public String getMessage() {
        return toString();
    }

}
